package  com.example.test.controller;
import com.example.test.entity.Params;
import com.example.test.entity.User;
import com.example.test.mapper.UserMapper;
import com.example.test.service.Userservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@CrossOrigin
@RestController
public class Usercontroller {
    @Autowired
   public Userservice userservice;

    @PostMapping("/register")
    public boolean InsertUser( String username, String password,Integer id) {
        if(findByName(username,password)){
            return false;
        }else{
        return userservice.InsertUser(username, password,id);
      }
    }
    @PostMapping("/login")
    public boolean findByName( String username, String password) {
        return userservice.findByName(username, password);
    }

    @PostMapping("deleteuser")
    public boolean deleteUser(@RequestParam String username) {
        return userservice.deleteUser(username);
    }

     @GetMapping("/getuser")
    public List<User> getUser() {
        return userservice.getUser();

     }
    @GetMapping("/getusername")
    public List<User> getUsername(String username,Integer id) {
        return userservice.getUsername(username, id);

    }


    }



